var ultis = {//这是一个方法库
    //将类数组转化为数组
    listToArray: function (likeArray) {
        var ary = [];
        try {
            ary = Array.prototype.slice.call(likeArray);
        } catch (e) {
            //如果浏览器不支持call方法则执行循环，逐条加入ary数组中
            for (var i = 0; i < likeArray.length; i++) {
                ary[ary.length] = likeArray[i];
            }
        }
        return ary;
    },
    //参数是属性名称,是一个字符串
    mySort: function () {
        var olis = document.getElementsByTagName('li');
            var olisArray = ultis.listToArray(olis);
            if(this.id == 'non'){
                for (let i = 0; i < olissArray.length; i++) {
                    const element = olissArray[i];
                    oul.appendChild(element);
    
                    
                }
                this.id = 'age';
                return;
            }
            
            if (this.id == 'age') {
            
            
            


                olisArray.sort(function (a, b) {
                    var spanlis1 = a.getElementsByTagName('span');
                    var spanlis2 = b.getElementsByTagName('span');
                    var spanArray1 = ultis.listToArray(spanlis1);
                    var spanArray2 = ultis.listToArray(spanlis2);
                    return parseFloat(spanArray1[1].innerHTML)
                        - parseFloat(spanArray2[1].innerHTML);
                })
            
                
                for (let i = 0; i < olisArray.length; i++) {
                    const element = olisArray[i];
                    oul.appendChild(element);

                    
                }

                this.id = 'non';
                return ;
        }

        
    }


}